import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;

public class Card {
	private int noc; // number of cases
	private Case[] cases;
	private QuickSort qs = new QuickSort();

	private void solve() throws IOException {
		Scanner sc = new Scanner(new FileReader("card_game.txt"));
		BufferedWriter bw = new BufferedWriter(new FileWriter("output1.txt"));
		noc = sc.nextInt();
		cases = new Case[noc];

		// get data
		for (int i = 0; i < noc; i++) {
			Case c = cases[i] = new Case();
			int N = c.N = sc.nextInt();
			c.K = sc.nextInt();
			c.data = new int[c.N];
			for (int j = 0; j < N; j++) {
				c.data[j] = sc.nextInt();
			}
			qs.sort(c.data);
		}

		// solve
		for (int i = 0; i < noc; i++) {
			Case c = cases[i];
			int max = 0;
			for (int j = c.data.length - 1, k = 0; j >= (c.K - 1); j--, k++) {
				max += c.data[j] * comb(c.N - k - 1, c.K - 1);
			}
			System.out.println("Case #" + (i + 1) + ": " + max);
			bw.write("Case #" + (i + 1) + ": " + max);
			if (i != noc - 1)
				bw.write("\n");
		}

		sc.close();
		bw.close();
	}

	public static void main(String args[]) throws IOException {
		new Card().solve();
	}

	/***************************** Utilities **********************************/
	private int comb(int n, int k) {
		return (fact(n) / (fact(k) * fact(n - k)));
	}

	private int fact(int k) {
		int result = 1;
		for (int i = 1; i <= k; i++)
			result *= i;

		return result;
	}

	private class Case {
		public int N;
		public int K;
		public int[] data;
	}

	private class QuickSort {
		private int[] numbers;
		private int number;

		public void sort(int[] values) {
			if (values == null || values.length == 0) {
				return;
			}
			this.numbers = values;
			number = values.length;
			quicksort(0, number - 1);
		}

		private void quicksort(int low, int high) {
			int i = low, j = high;
			int pivot = numbers[low + (high - low) / 2];

			// Divide into two lists
			while (i <= j) {

				while (numbers[i] < pivot) {
					i++;
				}

				while (numbers[j] > pivot) {
					j--;
				}

				if (i <= j) {
					exchange(i, j);
					i++;
					j--;
				}
			}
			// Recursion
			if (low < j)
				quicksort(low, j);
			if (i < high)
				quicksort(i, high);
		}

		private void exchange(int i, int j) {
			int temp = numbers[i];
			numbers[i] = numbers[j];
			numbers[j] = temp;
		}
	}
}
